package com.jerry.security.dao;

import com.jerry.security.model.Role;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author Jerry.Wu
 * @description:
 * @date 2018/9/4 16:53
 */
public interface RoleDao extends BaseDao<Role, Integer> {

    @Query(value = "select r.* from t_role r left join t_user_role ur on r.id = ur.role_id where ur.user_id = :userId", nativeQuery = true)
    List<Role> findRolesByUserId(@Param("userId") Integer userId);

}
